<template>
	<div class="wrapper">
         <div class="pr12 pb12">
                  <Card class="Position paC my-card1">
                    <tab-card
                      title="常用下载"
                      :card-title-list="cardTitleList1"
                      :content-index="1"
                      height="305"
                      @Open="moreClick('download','常用下载列表','/more-detail')"
                    >
                      <div>
                        <div
                          class="message-content flex-a"
                          v-for="(item,index) in download"
                          :key="index"
                          @click="openHref(item.url,'_blank')"
                        >
                          <p class="wh1 flex Position span-message" :id="`list${index}`">
                            <span
                              :title="item.title+'('+item.updateTime+')'"
                              class="span-Eli Ellipsis"
                              :style="{width:Width+'px'}"
                            >{{item.title}}({{ item.updateTime}})</span>
                          </p>
                        </div>
                      </div>
                    </tab-card>
                  </Card>
                </div>   
    </div>
</template>

<script>
import Cookies from 'js-cookie'
import { fromPost,openHref , screenW, onSize } from '@/libs/tool'
import {downloadResources} from '@/api/index.js'
import tabCard from "@/components/card/tabCard.vue";
export default {
	name: 'desingn-common-download',
	components: {tabCard},
	props: {},
	data() {
		return {
			cardTitleList1: [],
			userInfo: '', //用户信息
            accessToken: '',
                  download: [],
                  		Width: 0, //新闻宽度超出显示省略号
			screenWidth: screenW(), //屏幕宽度
		}
	},
		watch: {
			screenWidth(val) {
				this.screenWidth = val
				this.onWidth()
			},
		},
	computed: {},
	methods: {
        fromSummit: fromPost,
            openHref: openHref,
		init() {
			let userInfo = JSON.parse(Cookies.get('userInfo'))
			this.  downloadResources()
        },
           downloadResources() {
      //常用下载
      downloadResources({
        departmentId: this.userInfo.departmentId,
        num: 6
      }).then(res => {
        if (res.code == 200) {
          this.download = res.result;
        } else {
          this.$Message.error(res.message);
        }
      });
    },
		moreClick(type, name, path) {
			this.setStore('moreDetailType', {
				type: type,
				name: name,
				path: path,
			})
			this.$router.push({
				path: path,
			})
        },
                 onWidth() {
      let that = this;
      setTimeout(function() {
        that.Width= that.$refs.list0.clientWidth - 160;
      }, 0);
    },
	},
	created() {
		this.accessToken = this.getSession('accessToken')
		this.init()
	},
	mounted() {
        onSize(this, 'screenWidth') //监听赋值
		this.onWidth() //动态的添加宽度为了本页面的省略号才搞的
    },
}
</script>
<style lang="less" scoped>
.wrapper {
	width: 100%;
	height: 100%;
}
</style>
<style lang="less">
@import './less/home.less';
@import '../../styles/common.less';
.my-card {
	.ivu-card-body {
		padding: 10px 12px;
	}
}
.my-card1 {
	.ivu-card-body {
		padding: 0;
	}
}
</style>
<style scoped lang="less">
@import './less/page_home.less';
.demo-carousel {
	width: 100%;
	height: 100%;
}
.page_home_main {
	height: 100%;
}
.page_home_scroll {
	height: 100%;
	width: 100%;
}
</style>